/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-09-09
 * Time: 20:41
 */
public class BinaryTree {
    static class Node {
        public char val;
        public Node left;
        public Node right;

        public Node(char val) {
            this.val = val;
        }
    }
    private Node root;

    public void createTree() {
        Node node1 = new Node('A');
        Node node2 = new Node('B');
        Node node3 = new Node('C');
        Node node4 = new Node('D');
        Node node5 = new Node('E');
        Node node6 = new Node('F');

        root = node1;
        root.left = node2;
        root.right = node3;
        node2.left = node4;
        node2.right = node5;
        node3.right = node6;
    }
    //前序遍历
    public void preOrder(Node root) {
        if(root == null) {
            return;
        }
        System.out.println(root.val + " ");
        preOrder(root.left);
        preOrder(root.right);
    }
    //中序遍历
    public void inOrder(Node root) {
        if(root == null) {
            return;
        }
        preOrder(root.left);
        System.out.println(root.val + " ");
        preOrder(root.right);
    }
    //后序遍历
    public void postOrder(Node root) {
        if(root == null) {
            return;
        }
        preOrder(root.left);
        preOrder(root.right);
        System.out.println(root.val + " ");
    }
}
